//
//  YZAttDocInfoView.m
//  kuaiyi
//
//  Created by Liu on 16/5/5.
//
//

#import "YZAttDocInfoView.h"

#import "YZAttDocInfoUpView.h"
#import "YZAttDocInfoBelowView.h"
#import "YZAttDocInfoScrollView.H"

@interface YZAttDocInfoView ()

/**
 *  医生信息
 */
@property (nonatomic, strong) YZAttDocInfoUpView *upView;
/**
 *  接诊条件->医生简介
 */
@property (nonatomic, strong) YZAttDocInfoBelowView *belowView;

/**
 *  可滑动的label
 */
@property (nonatomic, strong) YZAttDocInfoScrollView *scrollView;

/**
 * 底部的Button
 */
@property (nonatomic , strong) UIButton *footBtn;

@end

@implementation YZAttDocInfoView


-(instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    //245 245 245
    self.backgroundColor = [UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1];
    [self addSubview:self.upView];
    [self addSubview:self.belowView];
    __weak YZAttDocInfoView *selfV = self;
    //接诊条件的回调
    self.belowView.belowConditionBlock = ^(){
        [UIView animateWithDuration:0.2 animations:^{
        selfV.scrollView.contentOffset = CGPointMake(0, 0) ;
        }];
    };
    //医生简介的回调
    self.belowView.belowDocIntroBlock = ^() {
        [UIView animateWithDuration:0.2 animations:^{
        selfV.scrollView.contentOffset = CGPointMake(375, 0) ;
        }];
    };
    
    [self addSubview:self.scrollView];

    //infoBlock
    self.scrollView.AttDocInfoBlock = ^(){
    
        if (self.scrollView.contentoffsetNewX > self.scrollView.contentOffset.x ) {
            //接诊条件按钮的点击
            [selfV.belowView bleowConditionBtnDidClock];
        }else {
            //医生简介按钮的点击
            [selfV.belowView belowDocIntroBtnDidClock];
        }

    };
    [self addSubview:self.footBtn];
    
    
    return self;
}

#pragma mark - 懒加载

-(UIView *)upView {
    if (_upView == nil) {
        _upView = [YZAttDocInfoUpView attDocInfoUpView];
        _upView.frame = CGRectMake(0, 64, 375, 100);
    }
    return _upView;
}
-(UIView *)belowView {
    if (_belowView == nil) {
        _belowView = [YZAttDocInfoBelowView attDocInfobelowView];
        _belowView.frame = CGRectMake(0, 174, 375, 50);
    }
    return _belowView;
}
-(UIScrollView *)scrollView {
    if (_scrollView == nil) {
        _scrollView = [[YZAttDocInfoScrollView alloc]init];
        _scrollView.frame = CGRectMake(0, 225, 375, 400);
        _scrollView.bounces = NO;
        _scrollView.showsHorizontalScrollIndicator = NO;
    }
    return _scrollView;
}
-(UIButton *)footBtn {
    if (_footBtn == nil) {
        _footBtn = [[UIButton alloc]init];
        _footBtn.frame = CGRectMake(10, 632, 355, 30);
        _footBtn.backgroundColor = [UIColor greenColor];
        [_footBtn setTitle:@"咨询医生" forState:UIControlStateNormal];
        [_footBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_footBtn addTarget:self action:@selector(footBtnDidClock) forControlEvents:UIControlEventTouchDown];
    }
    return _footBtn;
}

#pragma mark - 按钮的点击事件
-(void)footBtnDidClock {
    self.DocInfoBlock();
}

@end
